package mc.web.decorators;
/**
 * @author nickname
 * Dekorator columny zawierajacej date, format daty pobierany jest z pliku settings_pl.resource 
 **/  
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.jsp.PageContext;
import org.displaytag.decorator.DisplaytagColumnDecorator;
import org.displaytag.exception.DecoratorException;
import org.displaytag.properties.MediaTypeEnum;

public class DateColumnDecorator implements DisplaytagColumnDecorator {

	private Locale loc = new Locale("pl","PL");
	private ResourceBundle res = ResourceBundle.getBundle("settings", loc);
	
	SimpleDateFormat dateformat = new SimpleDateFormat(res.getString("data.format"));
	
	public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media) throws DecoratorException
    {
		
		return columnValue != null ? dateformat.format((Date) columnValue) : "" ;
		
    }

}
